package fr.rhoc.android;

import java.io.IOException;

import android.os.Handler;
import android.os.Message;
import android.util.Log;
import fr.rhoc.android.webservices.WebServicesUtils;


public class GetNbPlayersThread extends Thread {

	Handler mHandler;
	private String url;
	private int nbJoueurs = 0;
	private boolean OK = false;
	
    
	GetNbPlayersThread(Handler h, String url) {
        mHandler = h;
        this.url = url;
    }
	
	public void run() {
		
		try {

			String result = WebServicesUtils
					.callServiceAndGetResponseAsString(url, null);

			OK = true;
			nbJoueurs = Integer.valueOf(result);
			
			Message msg = mHandler.obtainMessage();
			mHandler.sendMessage(msg);
			
		} catch (IOException e) {
			Log.e("log_tag", "I/O Error getting WS answer " + e.toString());
		}
	}

	public int getNbJoueurs() {
		return nbJoueurs;
	}

	public boolean isOK() {
		return OK;
	}
	
	
}